module MC.View {
	export class MyNewsList {
		public constructor() {
			this.init();
		}
		private page: MC.Page;
		private Div: JQuery = null;
		private init() {
			this.Div = $('#newslist');
			this.page = new MC.Page('#newslist_loadbutton', "/api/my/pub/news-get", {},
				(list: any) => {
					console.log(list);
					this.showList(list);
				});
			this.page.init();
			let mthis=this;
			$('#newslist').on('click','.buttonList .deletebtn[newsid]',function(){
				let id=$(this).attr('newsid');
				MC.msg.confirm('是否删除该咨询?',()=>{
					MC.apiD('DeleteNews',{id:id},()=>{
						MC.msg.show('删除成功');
						location.reload();
					});
				});
			});//
		}
		private showList(list: any) {
			for (let i = 0; i < list.length; i++) {
				let one=list[i];
				if(!one.desc){
					one.desc='';
				}
				let html = `<div class="tab-panel-item tab-active"">
					<div class="aui-flex clearfix">
						<a class="aui-look-img" href="/h5/news/newsShow.html?newsShowId=`+one.id+`">
							<img
								src="`+one.thumb+`"
						></a>
						<div class="aui-flex-box">
							<a class="h3" href="/h5/news/newsShow.html?newsShowId=`+one.id+`">`+one.title+`</a>
							<a class="desc" href="/h5/news/newsShow.html?newsShowId=`+one.id+`">`+one.desc+`</a>
							<div class="buttonList" >
								<a class="editbtn btn none" href="/h5/index/addNews.html?id=`+one.id+`">编辑</a>
								<a class="deletebtn btn" newsid="`+one.id+`">删除</a>
								<span class="divdesc">浏览量:`+one.pv+`</span>
								<span class="praise">点赞:`+one.praise+`</span>
							</div>
						</div>
						<div class="orderNotice time_`+one.timestatus+`">`+one.statusName+`</div>
					</div>
				</div>`;
				this.Div.append(html);
			}


		}
	}
}